/*
Written by Best Flash Solutions, Inc  
See:
	http://www.bestflashsolutions.com
Contact me: contact@bestflashsolutions.com
*/

/**
 * Message notice in this application
 */
package com.bestflashsolutions.app
{
	import mx.controls.Alert;
	
	//
	//Message in application
	//
	public class Message
	{
		//3 Message types
		public static const ERROR: String = "Web Video Conference - Error";
		public static const WARNING: String = "Web Video Conference - Warning";
		public static const NOTICE: String = "Web Video Conference - Notice";
			
		//Here are messages in application
		public static const ERR_NO_AUDIO_DEVICE: Message = new Message(Message.ERROR, "You must have audio record device to join room.");
		public static const ERR_LOGIN_INCORRECT: Message = new Message(Message.ERROR, "Incorrect username or password.");
		public static const ERR_LOGIN_ALREADY: Message = new Message(Message.ERROR, "User is already logged in.");
		public static const ERR_WEBSERVER_UNKNOWN: Message = new Message(Message.ERROR, "Error when communicating to web server.");
		public static const ERR_ROOM_NOT_EXIST: Message = new Message(Message.ERROR, "Room does not exist. Please press Refresh first.");
		public static const ERR_ROOM_NOT_SELECT: Message = new Message(Message.ERROR, "No room is selected.");
		public static const ERR_ROOM_FULL_REFRESH: Message = new Message(Message.ERROR, "Room is full so some user cannot be display.");
		
		public static const ERR_ROOM_NO_NAME: Message = new Message(Message.ERROR, "Please enter room name.");
		public static const ERR_ROOM_CANNOT_CREATE: Message = new Message(Message.ERROR, "Cannot create room.");
		public static const ERR_RTMPSERVER_CANNOT_CONNECT: Message = new Message(Message.ERROR, "Cannot connect to streaming server.");
		public static const ERR_RTMPSERVER_STREAMING_ERROR: Message = new Message(Message.ERROR, "Error when receiving stream.");
		public static const ERR_RTMPSERVER_REJECT: Message = new Message(Message.ERROR, "Rejected by streaming server");
		public static const ERR_ROOM_FULL: Message = new Message(Message.ERROR, "Room is full. Please wait other person leave room and Join again.");
		public static const ERR_WEBSERVER_SAVE: Message = new Message(Message.ERROR, "Cannot save information.");

		public static const ERR_PHP_PATH_INCORRECT: Message = new Message(Message.ERROR, "Incorrect PHP path.");
		
		//Admin messages
		public static const ADMIN_ERR_DB_ERROR: Message = new Message(Message.ERROR, "Error in updating the DB.");
		public static const ADMIN_ERR_USER_ALREADY_EXIST: Message = new Message(Message.ERROR, "User already exist.");
		public static const ADMIN_ERR_VALUE_REQUIRED: Message = new Message(Message.ERROR, "Value required.");
		
		//Exceed number of send
		public static const CHAT_ERR_EXCEED_NUMBER_OF_SEND: Message = new Message("Error", "System only allows 1 message per second to avoid spammed content");
		
		public static const ADMIN_DB_UPDATED: Message = new Message("System", "DB updated...");
		
		public static const UPLOAD_COMPLETE: Message = new Message(Message.NOTICE, "Upload Complete");
		public static const PROVIDE_NOTE: Message = new Message(Message.ERROR, "Please Provide Note.");
		
		private var strMsg: String;
		private var strType: String;
		
		public function Message(type: String, message: String)
		{
			strMsg = message;
			strType = type;	
		}
		
		public function toString(): String {
			return strMsg;
		}
		
		public function get title(): String {
			return strType;		
		}
		
		//Show alert box (with confirm)
		public function alert(btn: uint = 4, closeHandler: Function=null):Alert {
			return Alert.show(strMsg, strType, btn,null,closeHandler,null, 4);
		}
	}
}